package com.ruoyi.market.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.db.domain.ChannelInfo;
import com.ruoyi.db.mapper.ChannelInfoMapper;
import com.ruoyi.db.model.param.ChannelInfoParam;
import com.ruoyi.market.constant.SysConstantType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.mapper.SysConstantInfoMapper;
import com.ruoyi.db.domain.SysConstantInfo;
import com.ruoyi.market.service.ISysConstantInfoService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 系统常量Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-08-04
 */
@Service
@DataSource(DataSourceType.SLAVE)
public class SysConstantInfoServiceImpl implements ISysConstantInfoService 
{
    @Autowired
    private SysConstantInfoMapper sysConstantInfoMapper;

    @Override
    public SysConstantInfo getEntryByType(String type)
    {
        return sysConstantInfoMapper.getEntryByType(type);
    }


    /**
     * 查询系统常量
     * 
     * @param id 系统常量主键
     * @return 系统常量
     */
    @Override
    public SysConstantInfo selectSysConstantInfoById(Long id)
    {
        return sysConstantInfoMapper.selectSysConstantInfoById(id);
    }

    /**
     * 查询系统常量列表
     * 
     * @param sysConstantInfo 系统常量
     * @return 系统常量
     */
    @Override
    public List<SysConstantInfo> selectSysConstantInfoList(SysConstantInfo sysConstantInfo)
    {
        return sysConstantInfoMapper.selectSysConstantInfoList(sysConstantInfo);
    }

    /**
     * 查询系统常量列表
     *
     * @param sysConstantInfo 系统常量
     * @return 系统常量
     */
    @Override
    public List<Map<String, Object>> selectSysConstantInfoListMap(SysConstantInfo sysConstantInfo)
    {
        return sysConstantInfoMapper.selectSysConstantInfoListMap(sysConstantInfo);
    }

    /**
     * 新增系统常量
     * 
     * @param sysConstantInfo 系统常量
     * @return 结果
     */
    @Override
    public int insertSysConstantInfo(SysConstantInfo sysConstantInfo)
    {
        sysConstantInfo.setCreateTime(DateUtils.getNowDate());
        return sysConstantInfoMapper.insertSysConstantInfo(sysConstantInfo);
    }

    /**
     * 修改系统常量
     * 
     * @param sysConstantInfo 系统常量
     * @return 结果
     */
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
    public int updateSysConstantInfo(SysConstantInfo sysConstantInfo)
    {
        // 判断类型
        int result = sysConstantInfoMapper.updateSysConstantInfo(sysConstantInfo);
        return result;
    }

    /**
     * 批量删除系统常量
     * 
     * @param ids 需要删除的系统常量主键
     * @return 结果
     */
    @Override
    public int deleteSysConstantInfoByIds(String ids)
    {
        return sysConstantInfoMapper.deleteSysConstantInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除系统常量信息
     * 
     * @param id 系统常量主键
     * @return 结果
     */
    @Override
    public int deleteSysConstantInfoById(Long id)
    {
        return sysConstantInfoMapper.deleteSysConstantInfoById(id);
    }
}
